package com.baizhi.controller;

import com.baizhi.entity.User;
import com.baizhi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
public class UserController {
    @Autowired
    private UserService us;
    @RequestMapping("/login")
    public boolean login(String nickname, String password, HttpSession session,String code){
        if (((String)session.getAttribute("codeData")).equalsIgnoreCase(code)){
            User login = us.selectlogin(nickname, password);
            if(login!=null){
                session.setAttribute("user",login);
                return true;
            }
        }
        return false;
    }
}
